//
//  UILabel+StringFrame.m
//  Longer3D
//
//  Created by 王大江 on 15/9/23.
//  Copyright (c) 2015年 longer3d. All rights reserved.
//

#import "UILabel+StringFrame.h"

@implementation UILabel (StringFrame)

- (CGSize)boundingRectWithSize:(CGSize)size
{
    NSDictionary *attribute = @{NSFontAttributeName: self.font};
    
    CGSize retSize = [self.text boundingRectWithSize:size
                                             options:
                      NSStringDrawingTruncatesLastVisibleLine |
                      NSStringDrawingUsesLineFragmentOrigin |
                      NSStringDrawingUsesFontLeading
                                          attributes:attribute
                                             context:nil].size;
    
    return retSize;
}


//- (UILabel *)setLabel:(UILabel *)label WithText:(NSString *)text Font:(UIFont *)font TextAlignment:(NSTextAlignment )alignment borderWidth:(CGFloat)borderWidth boderColor:(UIColor *)color CornerRadius:(CGFloat)radius{
//    
//    
//    [self setupLabel:label WithText:text Font:font TextAlignment:alignment borderWidth:borderWidth boderColor:color CornerRadius:radius];
//    label.layer.masksToBounds = YES;
//    return label;
//}
//
//- (UILabel *)setLabel:(UILabel *)label WithText:(NSString *)text Font:(UIFont *)font TextAlignment:(NSTextAlignment)alignment TextColor:(UIColor *)color{
//    
//   [self setupLabel:label WithText:text Font:font TextAlignment:alignment borderWidth:0 boderColor:[UIColor clearColor] CornerRadius:0];
//    return label;
//    
//}
//
//
//- (UILabel *)setLabel:(UILabel *)label WithText:(NSString *)text Font:(CGFloat)font{
//    
//    [self setupLabel:label WithText:text Font:[UIFont systemFontOfSize:font] TextAlignment:NSTextAlignmentLeft borderWidth:0 boderColor:[UIColor clearColor] CornerRadius:0];
//    return label;
//}
//
//
//
//- (void)setupLabel:(UILabel *)label WithText:(NSString *)text Font:(UIFont *)font TextAlignment:(NSTextAlignment )alignment borderWidth:(CGFloat)borderWidth boderColor:(UIColor *)color CornerRadius:(CGFloat)radius{
//    label.text = text;
//    label.font = font;
//    label.textAlignment = alignment;
//    label.layer.borderWidth = borderWidth;
//    label.layer.borderColor = color.CGColor;
//    label.layer.cornerRadius = radius;
//   
//}





- (void)setLabelWithText:(NSString *)text Font:(UIFont *)font{
    self.text = text;
    self.font = font;
}

- (void)setLabelWithText:(NSString *)text Font:(UIFont *)font TextColor:(UIColor *)textColor{
    [self setLabelWithText:text Font:font];
    self.textColor = textColor;
}

- (void)setLabelWithText:(NSString *)text Font:(UIFont *)font TextAlignment:(NSTextAlignment )alignment {
    [self setLabelWithText:text Font:font];
    self.textAlignment = alignment;
}

- (void)setLabelWithText:(NSString *)text Font:(UIFont *)font TextColor:(UIColor *)textColor TextAlignment:(NSTextAlignment )alignment{
    [self setLabelWithText:text Font:font TextColor:textColor];
    self.textAlignment = alignment;
}


- (void)setLabelWithText:(NSString *)text Font:(UIFont *)font TextAlignment:(NSTextAlignment )alignment borderWidth:(CGFloat)borderWidth boderColor:(UIColor *)color CornerRadius:(CGFloat)radius{
    [self setLabelWithText:text Font:font TextAlignment:alignment];
    self.layer.borderWidth = borderWidth;
    self.layer.borderColor = color.CGColor;
    self.layer.cornerRadius = radius;
}


@end
